/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_jolt_msg_data_node_free.c                        */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/01 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../src/module/tuxedojolt/config.h"
#include <tuxedojolt/jolt_core.h>
#include <tuxedojolt/jolt_header.h>
#include <tuxedojolt/jolt_comm.h>
#include <tuxedojolt/jolt_packet.h>
#include <tuxedojolt/jolt_mar.h>

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    L7_jolt_msg_data *p_st_jolt_msg_data = NULL;
    Frlist_node *p_st_node = NULL;

    p_st_jolt_msg_data = (L7_jolt_msg_data *) frmalloc(sizeof(L7_jolt_msg_data));
    CU_ASSERT_PTR_NOT_NULL(p_st_jolt_msg_data);

    memset(p_st_jolt_msg_data, 0x00, sizeof(L7_jolt_msg_data));
    p_st_jolt_msg_data->ui_type = APM_JOLT_SSHORT;
    p_st_jolt_msg_data->i_index = 0;
    p_st_jolt_msg_data->s_short = 1;
    p_st_node = frlist_node_create(p_st_jolt_msg_data);

    jolt_msg_data_node_free(p_st_node);
    CU_ASSERT_PTR_NULL(p_st_node->data);

    jolt_free((void **) &p_st_node);
}

int add_suite_jolt_msg_data_node_free(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" jolt_msg_data_node_free()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
